package com.oa.android.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.oa.android.R;
import com.oa.android.activity.SearchTxlActivity;
import com.oa.android.activity.TxlActivity;

/**
 * 通讯录
 * Created by zouqh on 2016/6/10.
 */
public class TxlFragment extends Fragment implements View.OnClickListener {

    View txlView;

    private RelativeLayout person,inside,shere;
    private TextView searchCru;

    //重写setMenuVisibility方法，不然会出现叠层的现象
    @Override
    public void setMenuVisibility(boolean menuVisibile) {
        super.setMenuVisibility(menuVisibile);
        if (this.getView() != null) {
            this.getView().setVisibility(menuVisibile ? View.VISIBLE : View.GONE);

        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        txlView = inflater.inflate(R.layout.txl_layout, container, false);
        person=(RelativeLayout)txlView.findViewById(R.id.geren);
        inside=(RelativeLayout)txlView.findViewById(R.id.neibu);
        shere=(RelativeLayout)txlView.findViewById(R.id.gongx);
        searchCru=(TextView)txlView.findViewById(R.id.searchCru);
        person.setOnClickListener(this);
        inside.setOnClickListener(this);
        shere.setOnClickListener(this);
        searchCru.setOnClickListener(this);
        return txlView;
    }

    @Override
    public void onClick(View v) {
        Intent intent=new Intent();
        switch (v.getId()){
            case R.id.geren:
                intent.setClass(getActivity(), TxlActivity.class);
                intent.putExtra("type","1");
                startActivity(intent);
                break;
            case R.id.neibu:
                intent.setClass(getActivity(), TxlActivity.class);
                intent.putExtra("type","3");
                startActivity(intent);
                break;
            case R.id.gongx:
                intent.setClass(getActivity(), TxlActivity.class);
                intent.putExtra("type","2");
                startActivity(intent);
                break;
            case R.id.searchCru:
                intent.setClass(getActivity(), SearchTxlActivity.class);
                intent.putExtra("type","1");
                startActivity(intent);
                break;
        }
    }
}
